| Conditions | 5 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | // import { URL } from 'url'; |
||
| 6 | export function resolveUrl(base, relativeUrl) { |
||
| 7 | const baseUrl = base ? new URL(base) : undefined; |
||
|
|
|||
| 8 | const absoluteUrl = new URL(relativeUrl, baseUrl); |
||
| 9 | |||
| 10 | if (absoluteUrl.href === relativeUrl) { |
||
| 11 | return new URL(absoluteUrl, baseUrl); |
||
| 12 | } |
||
| 13 | |||
| 14 | const apiPrefix = last(baseUrl.pathname) === '/' |
||
| 15 | ? baseUrl.pathname.slice(0, -1) |
||
| 16 | : baseUrl.pathname; |
||
| 17 | |||
| 18 | const relPath = apiPrefix |
||
| 19 | ? apiPrefix + absoluteUrl.pathname |
||
| 20 | : relativeUrl; |
||
| 21 | |||
| 22 | return new URL(relPath, baseUrl); |
||
| 23 | } |
||
| 24 | |||
| 38 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.